#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/07/31
# @Author   :Changshu
# @File     :practice_7.py


def reverse(x:int)->int:
	s=''
	if x==0:
		return 0
	str_x=str(x)
	if x<0:
		s+='-'
	s+=str_x[len(str_x)-1::-1].lstrip('0').rstrip('-')
	s=int(s)
	if -2**31<s<2**31-1:
		return s
	return 0

if __name__=='__main__':
	print(reverse(123))
